<template>
  <div class="registerDataContainer" ref="registerDataContainer">
    <div class="registerDataBox clearfix w1200">
      <div class="leftBox">
        <h1>{{ info.title }}</h1>
        <div class="userAndBtn flex align-center justify-between">
          <div class="userBox flex align-center">
            <i class="el-icon-date"></i>
            <span>{{ info.createTime }}</span>
          </div>
          <el-button type="primary" round size="mini" @click="subscribeHandler">订阅</el-button>
        </div>
        <div class="contentBox">
          <div class="remarkBox" v-html="info.remark">
          </div>
          <div class="content" v-html="info.content"></div>
        </div>
      </div>
      <div class="rightBox" :class="{fixed}">
        <div class="examineInfoBox">
          <h2>审核人信息</h2>
          <div class="examineInfoItem">
            <p><b>审核人姓名：</b>{{ info.examineUserName }}</p>
            <p><b>审核时间：</b>{{ info.examineTime }}</p>
            <p><b>审核建议：</b></p>
            <p>{{ info.examineSuggestion }}</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import {getRegisterDetail, dataSubscribe} from '@/api/compre/register'

export default {
  name: '',
  props: {},
  components: {},
  data() {
    return {
      appWrapper: null,
      fixed: false,
      info: {}
    }
  },
  computed: {},
  watch: {},
  created() {
    let id = this.$route.params.id;
    this.getDetail(id);
  },
  mounted() {
    this.$nextTick(() => {
      this.appWrapper = this.$refs.registerDataContainer;
      this.appWrapper.addEventListener("scroll", this.scrollFixedHeader, true);
    })
  },
  destroyed() {
    this.appWrapper.removeEventListener("scroll", this.scrollFixedHeader, true);
  },
  methods: {
    scrollFixedHeader(e) {
      let scrollTop = this.appWrapper.scrollTop;
      this.fixed = scrollTop > 106;
    },
    async getDetail(id) {
      let {code, data} = await getRegisterDetail(id);
      if (code === 200) {
        this.info = data;
      }
    },
    async subscribeHandler() {
      let {code, data, msg} = await dataSubscribe({
        registerId: this.info.id
      });
      if (code === 200) {
        this.$message({
          message: '订阅成功',
          type: 'success'
        });
      } else {
        this.$message({
          message: msg,
          type: 'error'
        });
      }
    }
  },
}
</script>
<style lang="scss" scoped>
.w1200 {
  width: 1200px;
  margin: 0 auto;
}

@mixin scrollBar {
  &::-webkit-scrollbar-track-piece {
    background: #d3dce6;
  }

  &::-webkit-scrollbar {
    width: 6px;
  }

  &::-webkit-scrollbar-thumb {
    background: #99a9bf;
    border-radius: 20px;
  }
}

.registerDataContainer {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  overflow-x: hidden;
  @include scrollBar;

  .registerDataBox {
    .leftBox {
      width: 824px;
      float: left;
      margin: 22px 0;
      box-shadow: 0 8px 16px 0 rgba(7, 17, 27, .05);
      border-radius: 12px;
      box-sizing: border-box;
      padding: 40px 40px 24px 40px;
      background: #fff;

      > h1 {
        font-size: 32px;
        color: #1c1f21;
        line-height: 40px;
        margin: 8px 0 20px;
        word-wrap: break-word;
        word-break: break-all;
      }

      .userAndBtn {
        height: 30px;

        .userBox {
          i {
            font-size: 18px;
            margin-right: 10px;
          }

          span {
            font-size: 14px;
          }
        }
      }

      .remarkBox {
        background-color: #F5F8F4;
        padding: 20px;
        margin: 30px 0;
        color: #333333;
        border-radius: 4px;
        font-size: 14px;
        line-height: 22px;
        text-indent: 2em;
      }
    }

    .rightBox {
      width: 356px;
      float: right;
      overflow-x: hidden;
      margin-top: 22px;
      box-shadow: 0 8px 16px 0 rgba(7, 17, 27, .05);
      border-radius: 12px;
      box-sizing: border-box;
      padding: 0 24px;
      @include scrollBar;
      background: #fff;

      &.fixed {
        position: fixed;
        top: 84px;
        margin-left: 844px;
      }
    }
  }
}

.examineInfoBox {
  padding-bottom: 24px;
  padding-top: 24px;

  > h2 {
    font-size: 16px;
    color: #07111b;
    font-weight: 700;
    margin: 0 0 24px;
  }

  .examineInfoItem {
    p {
      font-size: 14px;
      margin: 0;
      line-height: 30px;
    }
  }
}
</style>
